#!/bin/sh

. $(dirname $0)/system.conf


software_dir=$topdir/software

mkdir -p $software_dir
mkdir -p $software_dir/tarballs


if [ ! -d "$software_dir/$calamares_release" ]; then
    echo "start compile calamares..."
    if [ ! -f $software_dir/tarballs/$calamares_release/"$calamares_release".tar.gz ]; then
        cd $software_dir/tarballs &&                                                                   \
        wget https://gitee.com/babytech/sources/raw/master/calamares/"$calamares_release".tar.gz &&   \
	mkdir -p $software_dir/tarballs/$calamares_release &&                                          \
        cp "$calamares_release".tar.gz $software_dir/tarballs/$calamares_release
    fi
    tar xvf $software_dir/tarballs/$calamares_release/"$calamares_release".tar.gz -C $software_dir &&  \
    cd $calamares_dir &&                                                            \
    gcc calamares_bin.c -o calamares
    if [ ! -f $topdir/script/pty_connector ]; then
        echo "create the link for pty_connector..."
        ln -s $calamares_dir/calamares $topdir/script/pty_connector
    fi
else
    echo "calamares dir: $calamares_release has existed"
fi
